package net.oschina.app.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import net.oschina.app.R;
import net.oschina.app.adapter.BaseRecyclerViewAdapter;
import net.oschina.app.util.UIUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/4/6.
 */

public class CollectionAdapter extends BaseRecyclerViewAdapter{

    private final String[] mList;

    public CollectionAdapter(Context context) {
        super(context);
        mList = UIUtils.getStrings(R.array.myblog_items);

    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(parent.getContext(), R.layout.fragment_collection_item, null);
        CollectionHolder collectionHolder = new CollectionHolder(view);
        return collectionHolder;
    }

    @Override
    public int getItemCount() {
        return mList.length;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        CollectionHolder collectionHolder = (CollectionHolder) holder;
        collectionHolder.mTv.setText(mList[position]);

    }

    class CollectionHolder extends RecyclerView.ViewHolder{
        @BindView(R.id.collection_blog_item)
        TextView mTv;

        public CollectionHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
